package com.itheima.mapper;

import com.itheima.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface UserMapper {
    /**
     * 登录功能
     * @param username 用户名
     * @param password 密码
     * @return 查询结果
     */
    @Select("select * from tb_user where username=#{username} and password=#{password}")
    User login(@Param("username") String username, @Param("password") String password);

    /**
     * 根据用户名查找用户
     * @param name
     * @return
     */
    @Select("select * from tb_user where username=#{username}")
    User findUserByName(String name);

    /**
     * 添加用户
     * @param user
     */
    @Insert("INSERT INTO `db1`.`tb_user` VALUES (null, #{username}, #{password})")
    void insertUser(User user);
}
